package com.palfund.service;

import android.app.Service;
import android.content.Intent;
import android.os.Binder;
import android.os.IBinder;
import android.os.Parcel;
import android.os.RemoteException;
import android.util.Log;

public class CommunicationService extends Service {
    public CommunicationService() {
    }

    @Override
    public IBinder onBind(Intent intent) {
        return new CommunicationBinder();
    }

    class CommunicationBinder extends Binder {
        @Override
        protected boolean onTransact(int code, Parcel data, final Parcel reply, int flags) throws
                RemoteException {
            Log.i("CommunicationBinder", "---onTransact()--->" + Thread.currentThread().getName());
            //Activity发来的信息
            String msg = data.readString();
            Log.i("TAG", "来自Activity的msg=" + msg);
            //给Activity回复信息
            reply.writeString("你好,我是service...");
            return super.onTransact(code, data, reply, flags);
        }
    }
}
